import configparser
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
exclude_sections = ['core']

def get_sections(ini_conf, format='list'):
    sections = set(ini_conf.sections())
    output = list(sections - set(exclude_sections))  # 获取sections中不包含排除的项
    if format == 'list':
        return output
    elif format == 'string':
        return ' '.join(output)

def in_sections(ini_conf, section):
    sections = get_sections(ini_conf)
    return section in sections

if __name__ == '__main__':
    import sys
    args = sys.argv[1:]
    if len(args) < 2:
        raise AttributeError("传参错误")
    inifile = args[0]
    func = args[1]
    other_args = args[2:]

    conf = configparser.ConfigParser()
    conf.read(inifile)

    print(globals()[func](conf, *other_args))
